class Solution:
    def findNumberIn2DArray(self, matrix, target: int) -> bool:
        if matrix==[[]] or len(matrix)==0:
            return False
        bottom = 0
        left = len(matrix[0])-1
        while left>=0 and bottom<len(matrix):
            if matrix[bottom][left]>target:
                left -=1
            elif matrix[bottom][left]<target:
                bottom+=1
            else:
                return True
        if left==0 or bottom==len(matrix):
            return False
        return True
if __name__ == '__main__':
    s = Solution()
    print(s.findNumberIn2DArray([[-1, 3]], -1))